import type { ConsultOrderParams } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useConsultStore = defineStore(
  'consult',
  () => {
    // 病情描述数据
    const illnessInfo = ref<
      Pick<ConsultOrderParams, 'illnessDesc' | 'illnessTime' | 'consultFlag' | 'pictures'>
    >({
      illnessDesc: '',
      illnessTime: 1,
      consultFlag: 0,
      pictures: [],
    })

    // 极速问诊
    const type = ref('')
    // 问诊类型
    const illnessType = ref('')
    // 科室ID
    const depId = ref('')
    // 患者ID
    const patientId = ref('')
    // 图片列表
    const fileList = ref<UniHelper.UniFilePickerValue[]>([])

    const clear = () => {
      illnessInfo.value = {} as ConsultOrderParams
      type.value = ''
      illnessType.value = ''
      depId.value = ''
      patientId.value = ''
      fileList.value = []
    }

    return { illnessInfo, type, illnessType, depId, patientId, fileList, clear }
  },
  {
    persist: true,
  }
)
